home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Comm
/
term-source.lha
/
Extras
/
Source
/
term-Source.lha
/
PrintPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-17
|
7KB
|
310 lines
/*
** PrintPanel.c
**
** Control panel to set options for phonebook printing
**
** Copyright © 1990-1995 by Olaf `Olsen' Barthel
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_FILE=1, GAD_PLAIN, GAD_USE, GAD_CANCEL, GAD_OPTION };
STATIC UBYTE __far OutputFile[MAX_FILENAME_LENGTH] = "PRT:";
STATIC ULONG Flags = PRINT_SERIAL | PRINT_MODEM | PRINT_SCREEN | PRINT_TERMINAL | PRINT_USERNAME | PRINT_COMMENT;
STATIC BYTE Plain = FALSE;
VOID __regargs
PrintPanel(struct Window *Window,struct List *PhoneList,LONG Count)
{
struct LayoutHandle *Handle;
BYTE Result = FALSE;
if(Handle = LT_CreateHandleTags(Window -> WScreen,
LH_LocaleHook, &LocaleHook,
TAG_DONE))
{
struct Window *PanelWindow;
UBYTE Storage[6];
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, HORIZONTAL_KIND,
LA_LabelID, MSG_V36_0152,
TAG_DONE);
{
LT_New(Handle,
LA_Type, VERTICAL_KIND,
TAG_DONE);
{
LONG i;
for(i = 0 ; i < 6 ; i++)
{
if(i == 3)
{
LT_EndGroup(Handle);
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
}
if(Flags & (1L << i))
Storage[i] = TRUE;
else
Storage[i] = FALSE;
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_PRINTPANEL_INCLUDE_SERIAL_GAD + i,
LA_ID, GAD_OPTION + i,
LA_BYTE, &Storage[i],
TAG_DONE);
}
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type, VERTICAL_KIND,
LA_LabelID, MSG_V36_0153,
TAG_DONE);
{
LT_New(Handle,
LA_Type, STRING_KIND,
LA_LabelID, MSG_PRINTPANEL_OUTPUT_FILE_OR_DEVICE_GAD,
LA_ID, GAD_FILE,
LA_STRPTR, OutputFile,
LA_Chars, 30,
LAST_Picker, TRUE,
GTST_MaxChars, MAX_FILENAME_LENGTH - 1,
TAG_DONE);
LT_New(Handle,
LA_Type, CHECKBOX_KIND,
LA_LabelID, MSG_PRINTPANEL_PLAIN_TEXT_GAD,
LA_ID, GAD_PLAIN,
LA_BYTE, &Plain,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,
LA_Type,VERTICAL_KIND,
TAG_DONE);
{
LT_New(Handle,
LA_Type, XBAR_KIND,
LAXB_FullSize, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_New(Handle,LA_Type,HORIZONTAL_KIND,
LAGR_SameSize, TRUE,
LAGR_Spread, TRUE,
TAG_DONE);
{
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_USE_GAD,
LA_ID, GAD_USE,
LABT_ReturnKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_New(Handle,
LA_Type, BUTTON_KIND,
LA_LabelID, MSG_GLOBAL_CANCEL_GAD,
LA_ID, GAD_CANCEL,
LABT_EscKey, TRUE,
LABT_ExtraFat, TRUE,
TAG_DONE);
LT_EndGroup(Handle);
}
LT_EndGroup(Handle);
}
if(PanelWindow = LT_Layout(Handle,LocaleString(MSG_PRINTPANEL_OUTPUT_OPTIONS_TXT),NULL,0,0,IDCMP_CLOSEWINDOW,0,
LAWN_HelpHook, &GuideHook,
LAWN_Parent, Window,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_RMBTrap, TRUE,
WA_Activate, TRUE,
TAG_DONE))
{
struct IntuiMessage *Message;
BOOLEAN Done = FALSE;
ULONG MsgClass,
MsgQualifier;
UWORD MsgCode;
struct Gadget *MsgGadget;
GuideContext(CONTEXT_PRINT);
PushWindow(PanelWindow);
do
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
break;
while(Message = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort))
{
MsgClass = Message -> Class;
MsgQualifier = Message -> Qualifier;
MsgCode = Message -> Code;
MsgGadget = (struct Gadget *)Message -> IAddress;
GT_ReplyIMsg(Message);
LT_HandleInput(Handle,MsgQualifier,&MsgClass,&MsgCode,&MsgGadget);
if(MsgClass == IDCMP_CLOSEWINDOW)
Done = TRUE;
if(MsgClass == IDCMP_IDCMPUPDATE && MsgGadget -> GadgetID == GAD_FILE)
{
UBYTE DummyBuffer[MAX_FILENAME_LENGTH],
*DummyChar;
struct FileRequester *FileRequest;
LT_LockWindow(PanelWindow);
SplitFileName(OutputFile,&DummyChar,DummyBuffer);
if(!DummyChar[0])
{
DummyBuffer[0] = 0;
DummyChar = LocaleString(MSG_PRINTPANEL_FILENAME_TXT);
}
if(FileRequest = GetFile(PanelWindow,LocaleString(MSG_PRINTPANEL_SELECT_OUTPUT_FILE_TXT),DummyBuffer,DummyChar,DummyBuffer,NULL,FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
{
LT_SetAttributes(Handle,GAD_FILE,
GTST_String,DummyBuffer,
TAG_DONE);
FreeAslRequest(FileRequest);
}
LT_UnlockWindow(PanelWindow);
}
if(MsgClass == IDCMP_GADGETUP)
{
LONG i;
switch(MsgGadget -> GadgetID)
{
case GAD_USE:
LT_UpdateStrings(Handle);
Flags = NULL;
for(i = 0 ; i < 6 ; i++)
{
if(Storage[i])
Flags |= (1L << i);
}
Result = Done = TRUE;
break;
case GAD_CANCEL:
Done = TRUE;
break;
}
}
}
}
while(!Done);
PopWindow();
}
LT_DeleteHandle(Handle);
}
if(Result)
{
LONG Error = 0;
BPTR File;
if(File = Open(OutputFile,MODE_NEWFILE))
{
struct Window *ReqWindow;
struct EasyStruct Easy;
Easy . es_StructSize = sizeof(struct EasyStruct);
Easy . es_Flags = NULL;
Easy . es_Title = (UBYTE *)LocaleString(MSG_TERMAUX_TERM_REQUEST_TXT);
Easy . es_GadgetFormat = (UBYTE *)LocaleString(MSG_PRINT_STOP_TXT);
Easy . es_TextFormat = (UBYTE *)LocaleString(MSG_PRINT_PRINTING_PHONEBOOK_TXT);
if(ReqWindow = BuildEasyRequest(Window,&Easy,NULL))
{
struct PhoneNode *TempNode;
BYTE Continue = TRUE;
if(Count > 0)
{
for(TempNode = (struct PhoneNode *)PhoneList -> lh_Head ; Continue && TempNode -> VanillaNode . ln_Succ ; TempNode = (struct PhoneNode *)TempNode -> VanillaNode . ln_Succ)
{
if(TempNode -> Entry -> Count >= 0)
Continue = PrintEntry(File,ReqWindow,Plain,&Error,TempNode -> Entry,Flags);
}
}
else
{
for(TempNode = (struct PhoneNode *)PhoneList -> lh_Head ; Continue && TempNode -> VanillaNode . ln_Succ ; TempNode = (struct PhoneNode *)TempNode -> VanillaNode . ln_Succ)
Continue = PrintEntry(File,ReqWindow,Plain,&Error,TempNode -> Entry,Flags);
}
FreeSysRequest(ReqWindow);
}
Close(File);
if(PathPart(OutputFile) != OutputFile)
{
AddProtection(OutputFile,FIBF_EXECUTE);
if(Config -> MiscConfig -> CreateIcons)
AddIcon(OutputFile,FILETYPE_TEXT,TRUE);
}
}
else
Error = IoErr();
if(Error)
{
STRPTR ErrorString;
if(Fault(Error,"",SharedBuffer,MAX_FILENAME_LENGTH))
ErrorString = SharedBuffer;
else
ErrorString = "???";
MyEasyRequest(Window,LocaleString(MSG_PRINT_ERROR_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),Error,ErrorString);
}
}
}